<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <link th:href="@{/css/shop.css}" type="text/css" rel="stylesheet" />
    <link th:href="@{/css/Sellerber.css}" type="text/css"  rel="stylesheet" />
    <link th:href="@{/css/bkg_ui.css}" type="text/css"  rel="stylesheet" />
    <link th:href="@{/css/pagina.css}" type="text/css"  rel="stylesheet" />
    <link th:href="@{/font/css/font-awesome.min.css}"  rel="stylesheet" type="text/css" />
    <link th:href="@{/layui/css/layui.css}"  rel="stylesheet" type="text/css" />
    <script type="application/javascript" th:src="@{../js/jquery-1.9.1.min.js}"></script>
    <script th:href="@{/js/shopFrame.js}" type="text/javascript"></script>
    <script th:href="@{/js/Sellerber.js}" type="text/javascript"></script>
    <script type="application/javascript" th:src="@{../js/layer/layer.js}"></script>
    <script type="application/javascript" th:src="@{../js/laydate/laydate.js}"></script>
    <script th:src="@{/layui/layui.js}" type="text/javascript"></script>
    <script type="text/javascript" th:href="@{/js/proTree.js}" ></script>

    <title>会员管理</title>
</head>
<!--[if lt IE 9]>
<script th:href="@{/js/html5shiv.js}"></script>
<script th:href="@{/js/respond.min.js}"></script>
<script th:href="@{/js/css3-mediaqueries.js}"  type="text/javascript"></script>

<![endif]-->
<body>
<div class="margin" id="page_style">
    <div class="operation clearfix same_module mb15">
        <form id="pageFrm" th:action="@{/user/selectUserInfo}" method="post">
            <input type="hidden" th:value="${page.totalElements}" id="totalElements"/>
            <input type="hidden" th:value="${page.number}" id="number" name="pageNo"/>
            <input type="hidden" name="pageNo" id="pageNo"/>
            <!--<input type="hidden" name="pageSize" id="pageSize" value="1"/>-->
            <ul class="choice_search">
                <li class="clearfix col-xs-2 col-lg-2 col-ms-3 "><label class="label_name ">会员名称：</label>
                    <input name="nickName" th:value="${nickName==null}?'':${nickName}"  type="text"  class="form-control col-xs-6 col-lg-5"/></li>
                <li class="clearfix col-xs-2 col-lg-2 col-ms-3 "><label class="label_name ">用户账号：</label>
                    <input name="telephone" th:value="${telephone==null}?'':${telephone}"  type="text"  class="form-control col-xs-6 col-lg-5"/></li>
                <span style=" float:left; padding:0px 10px; line-height:32px;">用户状态</span>
                <li class="clearfix col-xs-4 col-lg-5 col-ms-5 ">
                    <select name="status" th:value="${status==1}?'':${status}">
                        <option value="-1">请选择用户状态</option>
                        <option value="1">启用</option>
                        <option value="0">禁用</option>
                    </select>
                </li>

                <a class="btn button_btn bg-deep-blue " onclick="page_nav(document.forms[0],this)"  type="button"><i class="fa  fa-search"></i>&nbsp;搜索</a>
            </ul>
        </form>
    </div>
    <div class="h_products_list clearfix" id="Sellerber">
        <div class="Sellerber_left menu" id="menuBar">
            <div class="show_btn" id="rightArrow"><span></span></div>
            <div class="side_title"><a title="隐藏" class="close_btn"><span></span></a></div>
            <div class="menu_style" id="menu_style">
                <div class="list_content">
                    <div class="side_list">
                        <div class="column_title"><h4 class="lighter smaller">会员等级列表</h4></div>
                        <div class="st_tree_style tree">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="bkg_List_style list_Exhibition list_show padding15">
            <div class="bkg_List_operation clearfix searchs_style">

            </div>
            <div class="datalist_show">
                <div class="bkg_List clearfix datatable_height confirm">
                    <table class="table  table_list table_striped table-bordered">
                        <thead>
                        <tr>
                            <th  width="40"><label><input type="checkbox" class="ace"><span class="lbl"></span></label></th>
                            <th>id</th>
                            <th>真实姓名</th>
                            <th>性别</th>
                            <th>电话</th>
                            <th>身份证</th>
                            <th>用户识别</th>
                            <th>状态</th>
                            <th>编辑</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr th:each="user : ${page.content}">
                            <td><label><input type="checkbox" class="ace"><span class="lbl"></span></label></td>
                            <td th:text="${user.userId}" class="uId"></td>
                            <td ><a onClick="userinfo(this)" th:text="${user.nickName}" th:id="${user.userId}"></a></td>
                            <td th:switch="${user.sex}">
                                <span th:case="1">男</span>
                                <span th:case="2">女</span>
                            </td>
                            <td th:text="${user.telephone}"></td>
                            <td th:text="${user.idCard}"></td>
                            <td th:text="${user.userIdentity}"></td>
                            <td th:switch="${user.status}">
                                <span th:case="1">启用</span>
                                <span th:case="0">禁用</span>
                            </td>
                            <td class="td-manage">
                                <label th:if="${user.status==1}">
                                    <a onclick="status(0,this)" th:id="${user.userId}" th:value="${user.status}" shiro:hasPermission="user:update" class="btn btn-xs btn-status">停用</a>
                                </label>
                                <label th:if="${user.status==0}">
                                    <a onclick="status(1,this)" th:id="${user.userId}" th:value="${user.status}" shiro:hasPermission="user:update" class="btn btn-xs btn-status">启用</a>
                                </label>
                            </td>
                        </tr>
                    </table>
                    <div id="this">
                    </div>
                    <!--<div id="paging">
                     <div class="pagination">
                      <lable th:if="${page.number+1}>1">
                       <a class='' title='首页' th:id="0" onclick="page_nav(document.forms[0],this);">首页</a>
                       <a class='' title='上一页' th:id="${page.number}-1"   onclick="page_nav(document.forms[0],this)">上一页</a>
                      </lable>
                      <lable th:if="${page.number+1}<=1">
                       <button class='disabled' disabled="disabled" title='首页' th:id="0" onclick="page_nav(document.forms[0],this);">首页</button>
                       <button class='disabled' disabled="disabled" title='上一页' th:id="${page.number}-1"   onclick="page_nav(document.forms[0],this)">上一页</button>
                      </lable>
                      <lable th:each=" i:${#numbers.sequence((page.number)-1,(page.number)+2)}">
                       <lable th:if="${i>=1&&i<=page.totalPages}">
                        <lable th:if="${i==page.number+1}">
                         <span class='current' th:text="${i}" th:id="${i}" onclick="page_nav(document.forms[0],this)"></span>
                        </lable>
                        <lable th:if="${i != page.number+1}">
                         <span th:text="${i}" th:id="${i}" onclick="page_nav(document.forms[0],this)"></span>
                        </lable>
                       </lable>
                      </lable>
                      <lable th:if="${page.number+1<page.totalPages}">
                       <a  th:id="${page.number}+1" onclick="page_nav(document.forms[0],this);">下一页</a>
                       <a  th:id="${page.totalPages}-1" onclick="page_nav(document.forms[0],this);">尾页</a>
                      </lable>
                      <lable th:unless="${page.number+1 != page.totalPages}">
                       <button class='disabled' disabled="disabled"  th:id="${page.number}+1" onclick="page_nav(document.forms[0],this);"aria-controls="datatable-responsive" data-dt-idx="1" tabindex="0">下一页</button>
                       <button class='disabled' disabled="disabled"  th:id="${page.totalPages}-1" onclick="page_nav(document.forms[0],this);">尾页</button>
                      </lable>
                     </div>
                    </div>-->
                </div>
            </div>
        </div>
    </div>
</div>

<!--添加用户图层-->
<div class="add_menber" id="add_menber_style" style="display:none">

    <ul class=" page-content">
        <li><label class="label_name">用&nbsp;&nbsp;户 &nbsp;名：</label><span class="add_name"><input value="" name="用户名" type="text"  class="text_add"/></span><div class="prompt r_f"></div></li>
        <li><label class="label_name">真实姓名：</label><span class="add_name"><input name="真实姓名" type="text"  class="text_add"/></span><div class="prompt r_f"></div></li>
        <li><label class="label_name">性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：</label><span class="add_name">
     <label><input name="form-field-radio" type="radio" checked="checked" class="ace"><span class="lbl">男</span></label>&nbsp;&nbsp;&nbsp;
     <label><input name="form-field-radio" type="radio" class="ace"><span class="lbl">女</span></label>&nbsp;&nbsp;&nbsp;
     <label><input name="form-field-radio" type="radio" class="ace"><span class="lbl">保密</span></label>
     </span>
            <div class="prompt r_f"></div>
        </li>
        <li><label class="label_name">固定电话：</label><span class="add_name"><input name="固定电话" type="text"  class="text_add"/></span><div class="prompt r_f"></div></li>
        <li><label class="label_name">移动电话：</label><span class="add_name"><input name="移动电话" type="text"  class="text_add"/></span><div class="prompt r_f"></div></li>
        <li><label class="label_name">电子邮箱：</label><span class="add_name"><input name="电子邮箱" type="text"  class="text_add"/></span><div class="prompt r_f"></div></li>
        <li class="adderss"><label class="label_name">家庭住址：</label><span class="add_name"><input name="家庭住址" type="text"  class="text_add" style=" width:350px"/></span><div class="prompt r_f"></div></li>
        <li><label class="label_name">状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：</label>
            <span class="add_name">
     <label><input name="form-field-radio1" type="radio" checked="checked" class="ace"><span class="lbl">开启</span></label>&nbsp;&nbsp;&nbsp;
     <label><input name="form-field-radio1" type="radio" class="ace"><span class="lbl">关闭</span></label>
     </span>
            <div class="prompt r_f"></div></li>
    </ul>
</div>
<!--用户信息-->
<div class="userinfo_style" id="userinfo_style" style="display: none" >

    <div class="member_show" id="userinfo_refresh" th:fragment="userinfo_refresh">

        <div class="member_jbxx clearfix" th:if="${userDetail!=null}">
            <img class="img" th:href="@{../images/user.png}">
            <dl  class="right_xxln" >
                <dt><span class="" th:text="${userDetail.nickName}"></span></dt>
                <dd class="" style="margin-left:0" th:text="${userDetail.signature}"></dd>
            </dl>
        </div>
        <div class="member_content" th:if="${userDetail!=null}">
            <ul>
                <li><label class="label_name">性别：</label><span class="name" th:text="${userDetail.sex}"></span></li>
                <li><label class="label_name">手机：</label><span class="name" th:text="${userDetail.telephone}"></span></li>
                <li><label class="label_name">登录时间：</label><span class="name" th:text="${userDetail.loginTime}"></span></li>
                <li><label class="label_name">用户标识：</label><span class="name" th:text="${userDetail.userIdentity}"></span></li>
            </ul>
        </div>

    </div>
</div>

<script>
    $(function () {
        pageloddd($("#totalElements").val(),$("#number").val(),5);
    })
    function page_nav(frm,obj){
        frm.pageNo.value =obj.id;
        frm.submit();
    };

    function status(status,obj) {
        var userId=obj.id;
        if(window.confirm("确定修改吗？")) {
            $.ajax({
                url: "/user/enableUser",
                method: "POST",
                data: {
                    status: status,
                    userid: userId
                },
                dataType: "json",
                success: function (data) {
                    if (data == 1) {
                        alert("修改成功");
                        location.href="/user/selectUserInfo";
                    } else {
                        alert("修改失败");
                    }
                }
            })
        }
    };
    function userinfo(obj){
        alert(obj.id);
        $.ajaxSettings.async = false;
        layer.open({
            type: 1,
            title: '用户信息',
            maxmin: true,
            shadeClose:false, //点击遮罩关闭层
            area : ['600px' , ''],
            content:$('#userinfo_style')
        });
        $.ajaxSettings.async = true;
        $("#userinfo_refresh").load("/user/selectUserDetails?userId="+obj.id);
    }
    $(".btn-status").click(function() {
        $.post("/Rouser/update", {}, function(result) {
            if(result.success) {
                alert(result.msg);
                return false;
            } else {
                alert(result.errorInfo);
                return false;
            }
        });
    });
    function pageloddd(totalElements,pageNum,pageSize){
        layui.use(['laypage'], function(){
            var laypage = layui.laypage
            //执行一个laypage实例
            var a=0;
            a=a+parseInt(pageNum)+1;
            laypage.render({
                elem: 'this' //注意，这里的 test1 是 ID，不用加 # 号
                ,count: totalElements //数据总数，从服务端得到
                ,curr:a
                ,layout: ['count', 'prev', 'page', 'next', 'skip']
                ,limit:pageSize  //每一页显示的条数
                ,skip:true
                ,jump: function(obj, first) {
                    //obj包含了当前分页的所有参数，比如：
                    console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                    console.log(obj.limit); //得到每页显示的条数
                    var aaa=obj.curr-1;
                    if(!first){
                        location.href="/user/selectUserInfo?pageNo="+aaa;
                    }
                }
            });
        });
    }
</script>
</body>
</html>
